package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.service.stockdept.pcfactorystockquery.ISurpAccService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-剩料确认作业")
@RoleCheck(prgIds = {"160112"})
public class PcSurpAccController {
    @Autowired
    private ISurpAccService service;

    @PostMapping("/getSurpAccHeadQuery")
    @ApiOperation(value = "剩料确认作业-剩料资料查询-可条件查询", tags = "仓储部-仓储工厂作业-剩料确认作业")
    public ResponseInfo getSurpAccHeadQuery(@RequestParam(required = false)@ApiParam("单据号") String slipNo,
                                            @RequestParam(required = false)@ApiParam("转入日期始")@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate slipDateStart,
                                            @RequestParam(required = false)@ApiParam("转入日期末")@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate slipDateEnd) {
        return service.getSurpAccHeadQuery(slipNo,slipDateStart,slipDateEnd);
    }

    @PostMapping("/getSurpAccDetailQuery")
    @ApiOperation(value = "剩料确认作业-转剩料仓明细-条件查询", tags = "仓储部-仓储工厂作业-剩料确认作业")
    public ResponseInfo getSurpAccDetailQuery(@RequestParam@ApiParam("单据号码") String slipNo) {
        return service.getSurpAccDetailQuery(slipNo);
    }

    @PostMapping("/getSurpAccDetail")
    @ApiOperation(value = "剩料确认作业-剩料资料删除-删除", tags = "仓储部-仓储工厂作业-剩料确认作业")
    public ResponseInfo getSurpAccDetail(@RequestParam@ApiParam("单据号码") String slipNo,
                                         @RequestParam@ApiParam("物料单号") String mtlNo) {
        return service.getSurpAaccDetail(slipNo,mtlNo);
    }

    @PutMapping("/getSurpAccUp")
    @ApiOperation(value = "剩料确认作业-确认/取消确认-更新", tags = "仓储部-仓储工厂作业-剩料确认作业")
    public ResponseInfo getSurpAccUp(@RequestBody@ApiParam("单据号码") List<String> slipNo,
                                     @RequestParam@ApiParam("1.确认 2.取消确认") Integer type) {
        return service.getSurpAccUp(slipNo,type);
    }
}
